<template>
  <div class="app-container">
    <el-card>
      <template #header>
        <div class="card-header">
          <span>设备维护</span>
        </div>
      </template>
      <div class="device-maintenance">
        <el-table :data="maintenanceList" style="width: 100%">
          <el-table-column prop="deviceName" label="设备名称" />
          <el-table-column prop="type" label="设备类型" />
          <el-table-column prop="lastMaintenance" label="上次维护" />
          <el-table-column prop="nextMaintenance" label="下次维护" />
          <el-table-column prop="status" label="状态">
            <template #default="scope">
              <el-tag
                :type="scope.row.status === '正常' ? 'success' : 'warning'"
              >
                {{ scope.row.status }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template #default="scope">
              <el-button size="small" @click="handleMaintenance(scope.row)"
                >维护</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref } from "vue";

const maintenanceList = ref([
  {
    deviceName: "1号变压器",
    type: "变压器",
    lastMaintenance: "2024-01-15",
    nextMaintenance: "2024-02-15",
    status: "正常",
  },
  {
    deviceName: "2号水泵",
    type: "水泵",
    lastMaintenance: "2024-01-10",
    nextMaintenance: "2024-02-10",
    status: "正常",
  },
  {
    deviceName: "3号发电机",
    type: "发电机",
    lastMaintenance: "2024-01-05",
    nextMaintenance: "2024-02-05",
    status: "需维护",
  },
]);

const handleMaintenance = (row) => {
  console.log("维护设备", row);
};
</script>

<style lang="scss" scoped>
.device-maintenance {
  padding: 20px;
}
</style>
